package com.renu.jdependencyanalyser.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public  class JarNode {
    private  String group;
    private  String artifact;
    private  String version;

    private   int  id ;

    private List<JarNode> children;

    private JarNode parent;
    public JarNode(String group, String artifact, String version, int cnt) {
        this.group = group;
        this.artifact = artifact;
        this.version = version;
        children = new ArrayList<>();
        //this.depth = depth;
        this.id = cnt;
    }

    public JarNode getParent() {
        return parent;
    }

    public void setParent(JarNode parent) {
        this.parent = parent;
    }

    //public int getDepth() {
    //    return depth;
    //}

    public JarNode() {
        children = new ArrayList<>();
    }

    @Override
    public String toString() {
        return group + ":" + artifact + ":" + version;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        JarNode that = (JarNode) o;
        return Objects.equals(artifact, that.artifact) && Objects.equals(version, that.version);
    }

    @Override
    public int hashCode() {
        return Objects.hash(artifact, version);
    }

    public  String toJarSig(){
        return  artifact +"-" + version+".jar";
    }

    public int getId() {
        return id;
    }

    public String getGroup() {
        return group;
    }

    public String getArtifact() {
        return artifact;
    }

    public String getVersion() {
        return version;
    }

    public List<JarNode> getChildren() {
        return children;
    }
}
